package com.heima.behavior.listener;

import com.alibaba.fastjson.JSON;
import com.heima.behavior.dto.FollowBehaviorDto;
import com.heima.behavior.service.IApFollowBehaviorService;
import com.heima.behavior.service.impl.ApFollowBehaviorServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
public class BehaviorListener {

    @Autowired
    private IApFollowBehaviorService apFollowBehaviorService;

    @KafkaListener(topics = "user_follow_behavior")
    public void receiveMsg(String msg){
        FollowBehaviorDto followBehaviorDto = JSON.parseObject(msg, FollowBehaviorDto.class);
        apFollowBehaviorService.saveBehavior(followBehaviorDto);
    }


}
